package com.yuanfeng.activity.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuanfeng.activity.dto.DiscountBaseDetailQueryDTO;
import com.yuanfeng.activity.dto.DiscountGoodsAddParamDTO;
import com.yuanfeng.activity.entity.ActivityDiscountGoodsEntity;
import com.yuanfeng.activity.vo.CheckDiscountLimitVO;
import com.yuanfeng.activity.vo.DiscountGoodsInfoVO;
import com.yuanfeng.activity.vo.DiscountGoodsListQueryResultVO;
import com.yuanfeng.activity.vo.DiscountGoodsListVO;
import com.yuanfeng.commoms.vo.activity.AppDiscountGoodsQueryResultVO;
import com.yuanfeng.commoms.vo.activity.CheckDiscountLimitResultVO;
import com.yuanfeng.commoms.vo.activity.ModularGoodsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @ClassName ActivityDiscountGoodsMapper
 * @Description 限时折扣商品表
 * @Author cyp
 * @Date 2023-05-25 14:10:08
 * @Version 1.0
 **/
@Mapper
public interface ActivityDiscountGoodsMapper extends BaseMapper<ActivityDiscountGoodsEntity> {

    /**
     * 查询限时折扣活动信息
     * @param goodsId
     * @return
     */
    AppDiscountGoodsQueryResultVO selectDiscountByGoodsId(@Param("goodsId") Integer goodsId);

    /**
     * 下单根据goodsid 查询活动详情
     * @param goodsId
     * @return
     */
    CheckDiscountLimitResultVO queryDiscountInfoByGoodsId(Integer goodsId);

    /**
     * 根据当前时间查询限时折扣活动信息 feign
     * @param goodsId
     * @return
     */
    AppDiscountGoodsQueryResultVO selectDiscountByGoodsIdAndTime(@Param("goodsId") Integer goodsId);

    /**
     * 查询限时折扣商品
     * @param param
     * @return
     */
    List<DiscountGoodsListQueryResultVO> queryDiscountLimitIndexGoods(@Param("param")Map<String, Object> param);

    /**
     * 查询限时折扣详情
     * @param commonId
     * @return
     */
    CheckDiscountLimitVO queryDiscountInfo(@Param("commonId") Integer commonId);

    /**
     * 查询用户购买当前商品数量
     * @param param
     * @return
     */
    Integer queryOrderGoodsCount(@Param("param")Map<String, Object> param);

    /**
     * 查询商品的commonId
     * @param discountId
     * @return
     */
    List<Integer> selectDiscountGoods(@Param("discountId")Integer discountId);

    /**
     * 获取其他正在进行的活动
     * @param discountId
     * @param commonId
     * @return
     */
    List<Integer> selectActiveDiscountGoods(@Param("discountId")Integer discountId,@Param("commonId")Integer commonId);

    /**
     * 删除
     * @param discountId
     */
    void deleteDiscountGoods(@Param("discountId")Integer discountId);

    /**
     * 是否存在或重复
     * @param commonId
     * @return
     */
    Integer checkSpecNum(Integer commonId);

    /**
     * 插入限时折扣的商品
     * @param param
     */
    void insertDiscountGoods(@Param("param") DiscountGoodsAddParamDTO param);

    /**
     * 修改限时折扣的商品
     * @param param
     */
    void updateDiscountGoods(@Param("param")DiscountGoodsAddParamDTO param);

    /**
     * 当前活动的商品信息
     * @param param
     * @return
     */
    IPage<DiscountGoodsListVO> selectDiscountGoodsDetail(IPage<DiscountGoodsListVO> page , @Param("param") DiscountBaseDetailQueryDTO param);


    /**
     * 当前活动的商品总数
     * @param param
     * @return
     */
    Integer selectDiscountGoodsDetailCount(@Param("param")  DiscountBaseDetailQueryDTO param);

    /**
     * 删除限时折扣的商品
     * @param param
     */
    void deleteDiscountGoods2(@Param("param") DiscountBaseDetailQueryDTO param);

    /**
     * 更新限时折扣价格
     * @param param
     */
    void updateDiscountGoodsPrice(@Param("param")DiscountGoodsAddParamDTO param);

    /**
     * 查询活动规格的活动价格
     * @param param
     * @return
     */
    List<DiscountGoodsListVO> selectDiscountGoodsDetail2(@Param("param")DiscountBaseDetailQueryDTO param);

    /**
     * 查询活动商品价格
     */
    ModularGoodsVO selectPriceByGoodsId(@Param("goodsId")Integer goodsId);

    void updateCommonIsXian2(@Param("commonIdList") List<Integer> commonIdList);


    IPage<DiscountGoodsListVO> queryDiscountGoodsInfo(IPage<DiscountGoodsListVO> page , @Param("param") Map<String, Object> param);


    DiscountGoodsInfoVO queryDiscountGoodsInfo2(@Param("param")  DiscountGoodsListVO discountGoodsListResult);


    List<String> queryBuyerUsers(@Param("param") DiscountGoodsListVO discountGoodsListResult);

    Integer queryCountForOlder(@Param("param")  Map<String,Object> paramMap);

    Integer queryUserOrderCount(@Param("param") Map<String, Object> paramMap);

    List<ActivityDiscountGoodsEntity> selectDiscountBaseDetail(@Param("id")Integer id);

}

